﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

using SSN.BusinessFramework.Jobs;
using SSN.Utilities.Database;
using SSN.Utilities.Security;
using SSN.DotNet;

namespace SSN.WebFramework
{
    public class JobManager
    {
        private static JobCache _JobCache = new JobCache();
        /// <summary>
        /// Returns all the jobs.
        /// </summary>
        public static ReadOnlyCollection<Job> AllJobs
        {
            get { return _JobCache.AllValues; }
        }

        /// <summary>
        /// Returns all the jobs.
        /// </summary>
        public static ReadOnlyDictionary<int, Job> JobsTable
        {
            get { return _JobCache.AllItems; }
        }

        /// <summary>
        /// Returns all the queued job items.
        /// </summary>
        public static List<JobQueueItem> AllJobQueueItems
        {
            get { return DbManager.BossDb.CreateListFromQueryFormat<JobQueueItem>(new AnonymousSecurityContext(), "SELECT * FROM {0}", JobQueueItem.TableName); }
        }

    }
}
